package by.home.controller;


import javax.servlet.*;
import java.io.IOException;

public class Encoding implements Filter {
    private String encoding;

    @Override
    public void init(FilterConfig filterConfig){
        this.encoding = filterConfig.getInitParameter("encoding");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException{
        request.setCharacterEncoding(encoding);
        filterChain.doFilter(request,response);
    }

    @Override
    public void destroy(){
        encoding = null;
    }
}
